Merge "Add SelfLinkBeginHook"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 28 May 2014 22:07:37 +0000 (22:07 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 28 May 2014 22:07:37 +0000 (22:07 +0000)
1  2 
docs/hooks.txt
includes/Linker.php

diff --combined docs/hooks.txt
@@@ -250,7 -250,6 +250,7 @@@ $block: The block from which the autobl
  'AbortEmailNotification': Can be used to cancel email notifications for an edit.
  $editor: The User who made the change.
  $title: The Title of the page that was edited.
 +$rc: The current RecentChange object.
  
  'AbortLogin': Return false to cancel account login.
  $user: the User object being authenticated against
@@@ -281,7 -280,7 +281,7 @@@ $title: the page titl
  'SendWatchlistEmailNotification': Return true to send watchlist email notification
  $targetUser: the user whom to send watchlist email notification
  $title: the page title
 -$this: EmailNotification object
 +$enotif: EmailNotification object
  
  'AbortChangePassword': Return false to cancel password change.
  $user: the User object to which the password change is occuring
@@@ -313,11 -312,11 +313,11 @@@ $apiModule: the ApiCreateAccount modul
  $loginForm: the LoginForm used
  &$result: associative array for API result data
  
 -'AfterFinalPageOutput': At the end of OutputPage::output() but before final
 -ob_end_flush() which will send the buffered output to the client. This allows
 -for last-minute modification of the output within the buffer by using
 -ob_get_clean().
 -&$output: OutputPage object
 +'AfterFinalPageOutput': Nearly at the end of OutputPage::output() but
 +before OutputPage::sendCacheControl() and final ob_end_flush() which
 +will send the buffered output to the client. This allows for last-minute
 +modification of the output within the buffer by using ob_get_clean().
 +$output: The OutputPage object where output() was called
  
  'AfterImportPage': When a page import is completed.
  $title: Title under which the revisions were imported
@@@ -326,6 -325,12 +326,6 @@@ $revCount: Number of revisions in the X
  $sRevCount: Number of successfully imported revisions
  $pageInfo: associative array of page information
  
 -'AfterFinalPageOutput': Nearly at the end of OutputPage::output() but
 -before OutputPage::sendCacheControl() and final ob_end_flush() which
 -will send the buffered output to the client. This allows for last-minute
 -modification of the output within the buffer by using ob_get_clean().
 -$output: The OutputPage object where output() was called
 -
  'AjaxAddScript': Called in output page just before the initialisation
  of the javascript ajax engine. The hook is only called when ajax
  is enabled ( $wgUseAjax = true; ).
@@@ -632,7 -637,6 +632,7 @@@ $title: Title corresponding to the arti
  $create: Whether or not the restoration caused the page to be created (i.e. it
    didn't exist before).
  $comment: The comment associated with the undeletion.
 +$oldPageId: ID of page previously deleted (from archive table)
  
  'ArticleUndeleteLogEntry': When a log entry is generated but not yet saved.
  $pageArchive: the PageArchive object
@@@ -728,13 -732,6 +728,13 @@@ $mediaWiki: Mediawiki objec
  &$out: OutputPage object
  &$skin: Skin object
  
 +'BeforeHttpsRedirect': Prior to forcing HTTP->HTTPS redirect. Gives a chance to
 +override how the redirect is output by modifying, or by returning false, and
 +letting standard HTTP rendering take place.
 +ATTENTION: This hook is likely to be removed soon due to overall design of the system.
 +$context: IContextSource object
 +&$redirect: string URL, modifiable
 +
  'BeforePageRedirect': Prior to sending an HTTP redirect. Gives a chance to
  override how the redirect is output by modifying, or by returning false and
  taking over the output.
@@@ -847,21 -844,6 +847,21 @@@ $changesList: ChangesList instanc
  $rows: The data that will be rendered. May be a ResultWrapper instance or
    an array.
  
 +'ChangesListSpecialPageFilters': Called after building form options on pages inheriting from ChangesListSpecialPage (in core: RecentChanges, RecentChangesLinked and Watchlist).
 +$special: ChangesListSpecialPage instance
 +&$filters: associative array of filter definitions. The keys are the HTML
 +  name/URL parameters. Each key maps to an associative array with a 'msg'
 +  (message key) and a 'default' value.
 +
 +'ChangesListSpecialPageQuery': Called when building SQL query on pages inheriting from ChangesListSpecialPage (in core: RecentChanges, RecentChangesLinked and Watchlist).
 +$name: name of the special page, e.g. 'Watchlist'
 +&$tables: array of tables to be queried
 +&$fields: array of columns to select
 +&$conds: array of WHERE conditionals for query
 +&$query_options: array of options for the database request
 +&$join_conds: join conditions for the tables
 +$opts: FormOptions for this request
 +
  'Collation::factory': Called if $wgCategoryCollation is an unknown collation.
  $collationName: Name of the collation in question
  &$collationObject: Null. Replace with a subclass of the Collation class that
@@@ -890,19 -872,6 +890,19 @@@ $title: the Title in question
  Handler functions that modify $ok should generally return false to prevent further
  hooks from further modifying $ok.
  
 +'ContentGetParserOutput': Customize parser output for a given content object,
 +called by AbstractContent::getParserOutput. May be used to override the normal
 +model-specific rendering of page content.
 +$content: The Content to render
 +$title: Title of the page, as context
 +$revId: The revision ID, as context
 +$options: ParserOptions for rendering. To avoid confusing the parser cache,
 +the output can only depend on parameters provided to this hook function, not on global state.
 +$generateHtml: boolean, indicating whether full HTML should be generated. If false,
 +generation of HTML may be skipped, but other information should still be present in the
 +ParserOutput object.
 +&$output: ParserOutput, to manipulate or replace
 +
  'ConvertContent': Called by AbstractContent::convert when a conversion to another
  content model is requested.
  $content: The Content object to be converted.
@@@ -1041,12 -1010,6 +1041,12 @@@ yourself. Alternatively, modifying $err
  contents of $error to be echoed at the top of the edit form as wikitext.
  Return true without altering $error to allow the edit to proceed.
  
 +'EditPage::showReadOnlyForm:initial: similar to EditPage::showEditForm:initial
 +but for the readonly 'view source' variant of the edit form.
 +$editor: EditPage instance (object)
 +&$out: an OutputPage instance to write to
 +return value is ignored (should alway return true)
 +
  'EditPage::showStandardInputs:options': allows injection of form fields into
  the editOptions area
  $editor: EditPage instance (object)
@@@ -1584,14 -1547,6 +1584,14 @@@ before the return
  &$attribs: the attributes to be applied.
  $linkType: The external link type
  
 +'LinkerMakeMediaLinkFile': At the end of Linker::makeMediaLinkFile() just
 +before the return.
 +$title: the Title object that the link is pointing to
 +$file: the File object or false if broken link
 +&$html: the link text
 +&$attribs: the attributes to be applied
 +&$ret: the value to return if your hook returns false
 +
  'LinksUpdate': At the beginning of LinksUpdate::doUpdate() just before the
  actual update.
  &$linksUpdate: the LinksUpdate object
@@@ -1639,11 -1594,6 +1639,11 @@@ localisation checks
  &$blacklist: array of checks to blacklist. See the bottom of
    maintenance/language/checkLanguage.inc for the format of this variable.
  
 +'LocalisationIgnoredOptionalMessages': When fetching the list of ignored and
 +optional localisation messages
 +&$ignored Array of ignored message keys
 +&$optional Array of optional message keys
 +
  'LogEventsListShowLogExtract': Called before the string is added to OutputPage.
  Returning false will prevent the string from being added to the OutputPage.
  &$s: html string to show for the log extract
@@@ -2117,7 -2067,7 +2117,7 @@@ configuration variables to JavaScript. 
  or request state must be added through MakeGlobalVariablesScript instead.
  &$vars: array( variable name => value )
  
 -'ResourceLoaderGetStartupModules': Run once the startup module is being
 +'ResourceLoaderGetStartupModules': DEPRECATED. Run once the startup module is being
  generated. This allows you to add modules to the startup module. This hook
  should be used sparingly since any module added here will be loaded on all
  pages. This hook is useful if you want to make code available to module loader
@@@ -2186,13 -2136,21 +2186,21 @@@ $title : Current Title object being dis
  'SearchableNamespaces': An option to modify which namespaces are searchable.
  &$arr : Array of namespaces ($nsId => $name) which will be used.
  
+ 'SelfLinkBegin': Called before a link to the current article is displayed to
+ allow the display of the link to be customized.
+ $nt: the Title object
+ &$html: html to display for the link
+ &$trail: optional text to display before $html
+ &$prefix: optional text to display after $html
+ &$ret: the value to return if your hook returns false
  'SetupAfterCache': Called in Setup.php, after cache objects are set
  
  'ShowMissingArticle': Called when generating the output for a non-existent page.
  $article: The article object corresponding to the page
  
  'ShowRawCssJs': Customise the output of raw CSS and JavaScript in page views.
 -DEPRECATED, use the ContentHandler facility to handle CSS and JavaScript!
 +DEPRECATED, use the ContentGetParserOutput hook instead!
  $text: Text being shown
  $title: Title of the custom script/stylesheet page
  $output: Current OutputPage object
@@@ -2247,12 -2205,6 +2255,12 @@@ $skin: Skin objec
  &$bar: Sidebar contents
  Modify $bar to add or modify sidebar portlets.
  
 +'SidebarBeforeOutput': Allows to edit sidebar just before its output by skins.
 +$skin Skin object
 +&$bar: Sidebar content
 +Modify $bar to add or modify sidebar portlets.
 +Warning: This hook is run on each display. You should consider to use 'SkinBuildSidebar' that is aggressively cached.
 +
  'SkinCopyrightFooter': Allow for site and per-namespace customization of
  copyright notice.
  $title: displayed page title
@@@ -2261,7 -2213,6 +2269,7 @@@ $type: 'normal' or 'history' for old/di
    message must be in HTML format, not wikitext!
  &$link: overridable HTML link to be passed into the message as $1
  &$forContent: overridable flag if copyright footer is shown in content language.
 +  This parameter is deprecated.
  
  'SkinGetPoweredBy': TODO
  &$text: additional 'powered by' icons in HTML. Note: Modern skin does not use
@@@ -2426,7 -2377,7 +2434,7 @@@ use this to change some selection crite
    result from the normal query
  
  'SpecialRecentChangesFilters': Called after building form options at
 -RecentChanges.
 +RecentChanges. Deprecated, use ChangesListSpecialPageFilters instead.
  $special: the special page object
  &$filters: associative array of filter definitions. The keys are the HTML
    name/URL parameters. Each key maps to an associative array with a 'msg'
@@@ -2438,8 -2389,7 +2446,8 @@@ SpecialRecentChanges
  $opts: FormOptions for this request
  
  'SpecialRecentChangesQuery': Called when building SQL query for
 -SpecialRecentChanges and SpecialRecentChangesLinked.
 +SpecialRecentChanges and SpecialRecentChangesLinked. Deprecated, use
 +ChangesListSpecialPageQuery instead.
  &$conds: array of WHERE conditionals for query
  &$tables: array of tables to be queried
  &$join_conds: join conditions for the tables
@@@ -2457,6 -2407,10 +2465,6 @@@ go to the existing page
  $t: title object searched for
  &$params: an array of the default message name and page title (as parameter)
  
 -'SpecialSearchGo': Called when user clicked the "Go".
 -&$title: title object generated from the text entered by the user
 -&$term: the search term entered by the user
 -
  'SpecialSearchNogomatch': Called when user clicked the "Go" button but the
  target doesn't exist.
  &$title: title object generated from the text entered by the user
@@@ -2490,6 -2444,14 +2498,6 @@@ $specialSearch: SpecialSearch object ($
  $output: $wgOut
  $term: Search term specified by the user
  
 -'SpecialSearchResultsAppend': Called after all search results HTML has
 -been output.  Note that in some cases, this hook will not be called (no
 -results, too many results, SpecialSearchResultsPrepend returned false,
 -etc).
 -$specialSearch: SpecialSearch object ($this)
 -$output: $wgOut
 -$term: Search term specified by the user
 -
  'SpecialSearchResults': Called before search result display when there are
  matches.
  $term: string of search term
@@@ -2509,8 -2471,7 +2517,8 @@@ Special:Upload
  $form: The SpecialUpload object
  
  'SpecialVersionExtensionTypes': Called when generating the extensions credits,
 -use this to change the tables headers.
 +use this to change the tables headers. Deprecated since MediaWiki 1.17, use the
 +ExtensionTypes hook instead.
  $extTypes: associative array of extensions types
  
  'SpecialVersionVersionUrl': Called when building the URL for Special:Version.
@@@ -2518,14 -2479,12 +2526,14 @@@ $wgVersion: Current $wgVersion for you 
  &$versionUrl: Raw url to link to (eg: release notes)
  
  'SpecialWatchlistFilters': Called after building form options at Watchlist.
 +Deprecated, use ChangesListSpecialPageFilters instead.
  $special: the special page object
  &$filters: associative array of filter definitions. The keys are the HTML
    name/URL parameters. Each key maps to an associative array with a 'msg'
    (message key) and a 'default' value.
  
  'SpecialWatchlistQuery': Called when building sql query for SpecialWatchlist.
 +Deprecated, use ChangesListSpecialPageQuery instead.
  &$conds: array of WHERE conditionals for query
  &$tables: array of tables to be queried
  &$join_conds: join conditions for the tables
@@@ -2624,7 -2583,7 +2632,7 @@@ $user: Current user objec
  &$whitelisted: Boolean value of whether this title is whitelisted
  
  'TitleSquidURLs': Called to determine which URLs to purge from HTTP caches.
 -$this: Title object to purge
 +$title: Title object to purge
  &$urls: An array of URLs to purge from the caches, to be manipulated.
  
  'UndeleteForm::showHistory': Called in UndeleteForm::showHistory, after a
@@@ -2950,12 -2909,6 +2958,12 @@@ Return false to prevent setting of the 
  &$expire: Cookie expiration, as for PHP's setcookie()
  $options: Options passed to WebResponse::setcookie()
  
 +'WhatLinksHereProps': Allows annotations to be added to WhatLinksHere
 +$row: The DB row of the entry.
 +$title: The Title of the page where the link comes FROM
 +$target: The Title of the page where the link goes TO
 +&$props: Array of HTML strings to display after the title.
 +
  'WikiExporter::dumpStableQuery': Get the SELECT query for "stable" revisions
  dumps. One, and only one hook should set this, and return false.
  &$tables: Database tables to use in the SELECT query
diff --combined includes/Linker.php
@@@ -30,6 -30,7 +30,6 @@@
   * @ingroup Skins
   */
  class Linker {
 -
        /**
         * Flags for userToolLinks()
         */
         * Get the appropriate HTML attributes to add to the "a" element of an
         * external link, as created by [wikisyntax].
         *
 -       * @param string $class the contents of the class attribute; if an empty
 +       * @param string $class The contents of the class attribute; if an empty
         *   string is passed, which is the default value, defaults to 'external'.
         * @return string
 -       * @deprecated since 1.18 Just pass the external class directly to something using Html::expandAttributes
 +       * @deprecated since 1.18 Just pass the external class directly to something
 +       *   using Html::expandAttributes.
         */
        static function getExternalLinkAttributes( $class = 'external' ) {
                wfDeprecated( __METHOD__, '1.18' );
        /**
         * Get the appropriate HTML attributes to add to the "a" element of an interwiki link.
         *
 -       * @param string $title the title text for the link, URL-encoded (???) but
 +       * @param string $title The title text for the link, URL-encoded (???) but
         *   not HTML-escaped
 -       * @param string $unused unused
 -       * @param string $class the contents of the class attribute; if an empty
 +       * @param string $unused Unused
 +       * @param string $class The contents of the class attribute; if an empty
         *   string is passed, which is the default value, defaults to 'external'.
         * @return string
         */
        /**
         * Get the appropriate HTML attributes to add to the "a" element of an internal link.
         *
 -       * @param string $title the title text for the link, URL-encoded (???) but
 +       * @param string $title The title text for the link, URL-encoded (???) but
         *   not HTML-escaped
 -       * @param string $unused unused
 -       * @param string $class the contents of the class attribute, default none
 +       * @param string $unused Unused
 +       * @param string $class The contents of the class attribute, default none
         * @return string
         */
        static function getInternalLinkAttributes( $title, $unused = null, $class = '' ) {
         * Get the appropriate HTML attributes to add to the "a" element of an internal
         * link, given the Title object for the page we want to link to.
         *
 -       * @param $nt Title
 -       * @param string $unused unused
 -       * @param string $class the contents of the class attribute, default none
 -       * @param $title Mixed: optional (unescaped) string to use in the title
 +       * @param Title $nt
 +       * @param string $unused Unused
 +       * @param string $class The contents of the class attribute, default none
 +       * @param string|bool $title Optional (unescaped) string to use in the title
         *   attribute; if false, default to the name of the page we're linking to
         * @return string
         */
        /**
         * Common code for getLinkAttributesX functions
         *
 -       * @param $title string
 -       * @param $class string
 +       * @param string $title
 +       * @param string $class
         *
         * @return string
         */
        /**
         * Return the CSS colour of a known link
         *
 -       * @param $t Title object
 -       * @param $threshold Integer: user defined threshold
 -       * @return String: CSS class
 +       * @param Title $t
 +       * @param int $threshold User defined threshold
 +       * @return string CSS class
         */
        public static function getLinkColour( $t, $threshold ) {
                $colour = '';
         *
         * @since 1.18 Method exists since 1.16 as non-static, made static in 1.18.
         *
 -       * @param $target        Title  Can currently only be a Title, but this may
 +       * @param Title $target Can currently only be a Title, but this may
         *   change to support Images, literal URLs, etc.
 -       * @param $html          string The HTML contents of the <a> element, i.e.,
 +       * @param string $html The HTML contents of the <a> element, i.e.,
         *   the link text.  This is raw HTML and will not be escaped.  If null,
         *   defaults to the prefixed text of the Title; or if the Title is just a
         *   fragment, the contents of the fragment.
 -       * @param array $customAttribs  A key => value array of extra HTML attributes,
 +       * @param array $customAttribs A key => value array of extra HTML attributes,
         *   such as title and class.  (href is ignored.)  Classes will be
         *   merged with the default classes, while other attributes will replace
         *   default attributes.  All passed attribute values will be HTML-escaped.
         *   A false attribute value means to suppress that attribute.
 -       * @param $query         array  The query string to append to the URL
 +       * @param array $query The query string to append to the URL
         *   you're linking to, in key => value array form.  Query keys and values
         *   will be URL-encoded.
 -       * @param string|array $options  String or array of strings:
 +       * @param string|array $options String or array of strings:
         *     'known': Page is known to exist, so don't check if it does.
         *     'broken': Page is known not to exist, so don't check if it does.
         *     'noclasses': Don't add any classes automatically (includes "new",
        /**
         * Returns the Url used to link to a Title
         *
 -       * @param $target Title
 +       * @param Title $target
         * @param array $query query parameters
 -       * @param $options Array
 -       * @return String
 +       * @param array $options
 +       * @return string
         */
        private static function linkUrl( $target, $query, $options ) {
                wfProfileIn( __METHOD__ );
        /**
         * Returns the array of attributes used when linking to the Title $target
         *
 -       * @param $target Title
 -       * @param $attribs
 -       * @param $options
 +       * @param Title $target
 +       * @param array $attribs
 +       * @param array $options
         *
         * @return array
         */
        /**
         * Default text of the links to the Title $target
         *
 -       * @param $target Title
 +       * @param Title $target
         *
         * @return string
         */
                if ( $target->getPrefixedText() === '' && $target->hasFragment() ) {
                        return htmlspecialchars( $target->getFragment() );
                }
 +
                return htmlspecialchars( $target->getPrefixedText() );
        }
  
        /**
 -       * Make appropriate markup for a link to the current article. This is currently rendered
 -       * as the bold link text. The calling sequence is the same as the other make*LinkObj static functions,
 -       * despite $query not being used.
 +       * Make appropriate markup for a link to the current article. This is
 +       * currently rendered as the bold link text. The calling sequence is the
 +       * same as the other make*LinkObj static functions, despite $query not
 +       * being used.
         *
 -       * @param $nt Title
 +       * @param Title $nt
         * @param string $html [optional]
         * @param string $query [optional]
         * @param string $trail [optional]
         * @param string $prefix [optional]
         *
 -       *
         * @return string
         */
        public static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '' ) {
+               $ret = "<strong class=\"selflink\">{$prefix}{$html}</strong>{$trail}";
+               if ( !wfRunHooks( 'SelfLinkBegin', array( $nt, &$html, &$trail, &$prefix, &$ret ) ) ) {
+                       return $ret;
+               }
                if ( $html == '' ) {
                        $html = htmlspecialchars( $nt->getPrefixedText() );
                }
         * This should be called after a method like Title::makeTitleSafe() returned
         * a value indicating that the title object is invalid.
         *
 -       * @param $context IContextSource context to use to get the messages
 +       * @param IContextSource $context Context to use to get the messages
         * @param int $namespace Namespace number
         * @param string $title Text of the title, without the namespace part
         * @return string
        }
  
        /**
 -       * @param $title Title
 +       * @param Title $title
         * @return Title
         */
        static function normaliseSpecialPage( Title $title ) {
         * Returns the filename part of an url.
         * Used as alternative text for external images.
         *
 -       * @param $url string
 +       * @param string $url
         *
         * @return string
         */
         * Return the code for images which were added via external links,
         * via Parser::maybeMakeExternalImage().
         *
 -       * @param $url
 -       * @param $alt
 +       * @param string $url
 +       * @param string $alt
         *
         * @return string
         */
                $img = '';
                $success = wfRunHooks( 'LinkerMakeExternalImage', array( &$url, &$alt, &$img ) );
                if ( !$success ) {
 -                      wfDebug( "Hook LinkerMakeExternalImage changed the output of external image with url {$url} and alt text {$alt} to {$img}\n", true );
 +                      wfDebug( "Hook LinkerMakeExternalImage changed the output of external image "
 +                              . "with url {$url} and alt text {$alt} to {$img}\n", true );
                        return $img;
                }
                return Html::element( 'img',
         * Given parameters derived from [[Image:Foo|options...]], generate the
         * HTML that that syntax inserts in the page.
         *
 -       * @param $parser Parser object
 -       * @param $title Title object of the file (not the currently viewed page)
 -       * @param $file File object, or false if it doesn't exist
 -       * @param array $frameParams associative array of parameters external to the media handler.
 +       * @param Parser $parser
 +       * @param Title $title Title object of the file (not the currently viewed page)
 +       * @param File $file File object, or false if it doesn't exist
 +       * @param array $frameParams Associative array of parameters external to the media handler.
         *     Boolean parameters are indicated by presence or absence, the value is arbitrary and
         *     will often be false.
         *          thumbnail       If present, downscale and frame
         *          link-target     Value for the target attribute, only with link-url
         *          no-link         Boolean, suppress description link
         *
 -       * @param array $handlerParams associative array of media handler parameters, to be passed
 +       * @param array $handlerParams Associative array of media handler parameters, to be passed
         *       to transform(). Typical keys are "width" and "page".
 -       * @param string $time timestamp of the file, set as false for current
 -       * @param string $query query params for desc url
 -       * @param $widthOption: Used by the parser to remember the user preference thumbnailsize
 +       * @param string|bool $time Timestamp of the file, set as false for current
 +       * @param string $query Query params for desc url
 +       * @param int|null $widthOption Used by the parser to remember the user preference thumbnailsize
         * @since 1.20
 -       * @return String: HTML for an image, with links, wrappers, etc.
 +       * @return string HTML for an image, with links, wrappers, etc.
         */
 -      public static function makeImageLink( /*Parser*/ $parser, Title $title, $file, $frameParams = array(),
 -              $handlerParams = array(), $time = false, $query = "", $widthOption = null
 +      public static function makeImageLink( /*Parser*/ $parser, Title $title,
 +              $file, $frameParams = array(), $handlerParams = array(), $time = false,
 +              $query = "", $widthOption = null
        ) {
                $res = null;
                $dummy = new DummyLinker;
                                $hp['width'] = $file->getWidth( $page );
                        }
  
 -                      if ( isset( $fp['thumbnail'] ) || isset( $fp['manualthumb'] ) || isset( $fp['framed'] ) || isset( $fp['frameless'] ) || !$hp['width'] ) {
 +                      if ( isset( $fp['thumbnail'] )
 +                              || isset( $fp['manualthumb'] )
 +                              || isset( $fp['framed'] )
 +                              || isset( $fp['frameless'] )
 +                              || !$hp['width']
 +                      ) {
                                global $wgThumbLimits, $wgThumbUpright;
 +
                                if ( $widthOption === null || !isset( $wgThumbLimits[$widthOption] ) ) {
                                        $widthOption = User::getDefaultOption( 'thumbsize' );
                                }
  
                                // Reduce width for upright images when parameter 'upright' is used
 +                              $useSquare = !isset( $fp['upright'] );
                                if ( isset( $fp['upright'] ) && $fp['upright'] == 0 ) {
                                        $fp['upright'] = $wgThumbUpright;
                                }
 -                              // For caching health: If width scaled down due to upright parameter, round to full __0 pixel to avoid the creation of a lot of odd thumbs
 +
 +                              // For caching health: If width scaled down due to upright
 +                              // parameter, round to full __0 pixel to avoid the creation of a
 +                              // lot of odd thumbs.
                                $prefWidth = isset( $fp['upright'] ) ?
                                        round( $wgThumbLimits[$widthOption] * $fp['upright'], -1 ) :
                                        $wgThumbLimits[$widthOption];
  
 -                              // Use width which is smaller: real image width or user preference width
 +                              // Use whichever is smaller: real image width or user preference width
                                // Unless image is scalable vector.
                                if ( !isset( $hp['height'] ) && ( $hp['width'] <= 0 ||
 -                                              $prefWidth < $hp['width'] || $file->isVectorized() ) ) {
 +                                              $prefWidth < $hp['width'] ||
 +                                              ( $useSquare && $prefWidth < $file->getHeight( $page ) ) ||
 +                                              $file->isVectorized() ) ) {
                                        $hp['width'] = $prefWidth;
 +                                      if ( $useSquare ) {
 +                                              $hp['height'] = $prefWidth;
 +                                      }
                                }
                        }
                }
  
                if ( $file && isset( $fp['frameless'] ) ) {
                        $srcWidth = $file->getWidth( $page );
 -                      # For "frameless" option: do not present an image bigger than the source (for bitmap-style images)
 -                      # This is the same behavior as the "thumb" option does it already.
 +                      # For "frameless" option: do not present an image bigger than the
 +                      # source (for bitmap-style images). This is the same behavior as the
 +                      # "thumb" option does it already.
                        if ( $srcWidth && !$file->mustRender() && $hp['width'] > $srcWidth ) {
                                $hp['width'] = $srcWidth;
                        }
  
        /**
         * Make HTML for a thumbnail including image, border and caption
 -       * @param $title Title object
 -       * @param $file File object or false if it doesn't exist
 -       * @param $label String
 -       * @param $alt String
 -       * @param $align String
 -       * @param $params Array
 -       * @param $framed Boolean
 -       * @param $manualthumb String
 -       * @return mixed
 +       * @param Title $title
 +       * @param File|bool $file File object or false if it doesn't exist
 +       * @param string $label
 +       * @param string $alt
 +       * @param string $align
 +       * @param array $params
 +       * @param bool $framed
 +       * @param string $manualthumb
 +       * @return string
         */
        public static function makeThumbLinkObj( Title $title, $file, $label = '', $alt,
                $align = 'right', $params = array(), $framed = false, $manualthumb = ""
        }
  
        /**
 -       * @param $title Title
 -       * @param $file File
 +       * @param Title $title
 +       * @param File $file
         * @param array $frameParams
         * @param array $handlerParams
         * @param bool $time
         * @param string $query
 -       * @return mixed
 +       * @return string
         */
        public static function makeThumbLink2( Title $title, $file, $frameParams = array(),
                $handlerParams = array(), $time = false, $query = ""
                        $fp['link-url'] = $url;
                }
  
 -              $s = "<div class=\"thumb t{$fp['align']}\"><div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
 +              $s = "<div class=\"thumb t{$fp['align']}\">"
 +                      . "<div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
 +
                if ( !$exists ) {
                        $s .= self::makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time == true );
                        $zoomIcon = '';
                        $params = array(
                                'alt' => $fp['alt'],
                                'title' => $fp['title'],
 -                              'img-class' => ( isset( $fp['class'] ) && $fp['class'] !== '' ? $fp['class'] . ' ' : '' ) . 'thumbimage'
 +                              'img-class' => ( isset( $fp['class'] ) && $fp['class'] !== ''
 +                                      ? $fp['class'] . ' '
 +                                      : '' ) . 'thumbimage'
                        );
                        $params = self::getImageLinkMTOParams( $fp, $query ) + $params;
                        $s .= $thumb->toHtml( $params );
                                                'class' => 'internal',
                                                'title' => wfMessage( 'thumbnail-more' )->text() ),
                                                Html::element( 'img', array(
 -                                                      'src' => $wgStylePath . '/common/images/magnify-clip' . ( $wgContLang->isRTL() ? '-rtl' : '' ) . '.png',
 +                                                      'src' => $wgStylePath . '/common/images/magnify-clip'
 +                                                              . ( $wgContLang->isRTL() ? '-rtl' : '' ) . '.png',
                                                        'width' => 15,
                                                        'height' => 11,
                                                        'alt' => "" ) ) ) );
         *
         * @param File $file
         * @param MediaTransformOutput $thumb
 -       * @param array $hp image parameters
 +       * @param array $hp Image parameters
         */
        public static function processResponsiveImages( $file, $thumb, $hp ) {
                global $wgResponsiveImages;
        /**
         * Make a "broken" link to an image
         *
 -       * @param $title Title object
 -       * @param string $label link label (plain text)
 -       * @param string $query query string
 -       * @param $unused1 Unused parameter kept for b/c
 -       * @param $unused2 Unused parameter kept for b/c
 -       * @param $time Boolean: a file of a certain timestamp was requested
 -       * @return String
 +       * @param Title $title
 +       * @param string $label Link label (plain text)
 +       * @param string $query Query string
 +       * @param string $unused1 Unused parameter kept for b/c
 +       * @param string $unused2 Unused parameter kept for b/c
 +       * @param bool $time A file of a certain timestamp was requested
 +       * @return string
         */
 -      public static function makeBrokenImageLinkObj( $title, $label = '', $query = '', $unused1 = '', $unused2 = '', $time = false ) {
 +      public static function makeBrokenImageLinkObj( $title, $label = '',
 +              $query = '', $unused1 = '', $unused2 = '', $time = false
 +      ) {
                global $wgEnableUploads, $wgUploadMissingFileUrl, $wgUploadNavigationUrl;
                if ( ! $title instanceof Title ) {
                        return "<!-- ERROR -->" . htmlspecialchars( $label );
                $encLabel = htmlspecialchars( $label );
                $currentExists = $time ? ( wfFindFile( $title ) != false ) : false;
  
 -              if ( ( $wgUploadMissingFileUrl || $wgUploadNavigationUrl || $wgEnableUploads ) && !$currentExists ) {
 +              if ( ( $wgUploadMissingFileUrl || $wgUploadNavigationUrl || $wgEnableUploads )
 +                      && !$currentExists
 +              ) {
                        $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title );
  
                        if ( $redir ) {
        /**
         * Get the URL to upload a certain file
         *
 -       * @param $destFile Title object of the file to upload
 -       * @param string $query urlencoded query string to prepend
 -       * @return String: urlencoded URL
 +       * @param Title $destFile Title object of the file to upload
 +       * @param string $query Urlencoded query string to prepend
 +       * @return string Urlencoded URL
         */
        protected static function getUploadUrl( $destFile, $query = '' ) {
                global $wgUploadMissingFileUrl, $wgUploadNavigationUrl;
        /**
         * Create a direct link to a given uploaded file.
         *
 -       * @param $title Title object.
 -       * @param string $html pre-sanitized HTML
 +       * @param Title $title
 +       * @param string $html Pre-sanitized HTML
         * @param string $time MW timestamp of file creation time
 -       * @return String: HTML
 +       * @return string HTML
         */
        public static function makeMediaLinkObj( $title, $html = '', $time = false ) {
                $img = wfFindFile( $title, array( 'time' => $time ) );
         * Create a direct link to a given uploaded file.
         * This will make a broken link if $file is false.
         *
 -       * @param $title Title object.
 -       * @param $file File|bool mixed File object or false
 -       * @param string $html pre-sanitized HTML
 -       * @return String: HTML
 +       * @param Title $title
 +       * @param File|bool $file File object or false
 +       * @param string $html Pre-sanitized HTML
 +       * @return string HTML
         *
         * @todo Handle invalid or missing images better.
         */
                        $url = self::getUploadUrl( $title );
                        $class = 'new';
                }
 -              $alt = htmlspecialchars( $title->getText(), ENT_QUOTES );
 +
 +              $alt = $title->getText();
                if ( $html == '' ) {
                        $html = $alt;
                }
 -              $u = htmlspecialchars( $url );
 -              return "<a href=\"{$u}\" class=\"$class\" title=\"{$alt}\">{$html}</a>";
 +
 +              $ret = '';
 +              $attribs = array(
 +                      'href' => $url,
 +                      'class' => $class,
 +                      'title' => $alt
 +              );
 +
 +              if ( !wfRunHooks( 'LinkerMakeMediaLinkFile',
 +                      array( $title, $file, &$html, &$attribs, &$ret ) ) ) {
 +                      wfDebug( "Hook LinkerMakeMediaLinkFile changed the output of link "
 +                              . "with url {$url} and text {$html} to {$ret}\n", true );
 +                      return $ret;
 +              }
 +
 +              return Html::rawElement( 'a', $attribs, $html );
        }
  
        /**
         * a message key from the link text.
         * Usage example: Linker::specialLink( 'Recentchanges' )
         *
 +       * @param string $name
 +       * @param string $key
         * @return string
         */
        public static function specialLink( $name, $key = '' ) {
        /**
         * Make an external link
         * @param string $url URL to link to
 -       * @param string $text text of link
 -       * @param $escape Boolean: do we escape the link text?
 -       * @param string $linktype type of external link. Gets added to the classes
 -       * @param array $attribs of extra attributes to <a>
 -       * @param $title Title|null Title object used for title specific link attributes
 +       * @param string $text Text of link
 +       * @param bool $escape Do we escape the link text?
 +       * @param string $linktype Type of external link. Gets added to the classes
 +       * @param array $attribs Array of extra attributes to <a>
 +       * @param Title|null $title Title object used for title specific link attributes
         * @return string
         */
 -      public static function makeExternalLink( $url, $text, $escape = true, $linktype = '', $attribs = array(), $title = null ) {
 +      public static function makeExternalLink( $url, $text, $escape = true,
 +              $linktype = '', $attribs = array(), $title = null
 +      ) {
                global $wgTitle;
                $class = "external";
                if ( $linktype ) {
                $success = wfRunHooks( 'LinkerMakeExternalLink',
                        array( &$url, &$text, &$link, &$attribs, $linktype ) );
                if ( !$success ) {
 -                      wfDebug( "Hook LinkerMakeExternalLink changed the output of link with url {$url} and text {$text} to {$link}\n", true );
 +                      wfDebug( "Hook LinkerMakeExternalLink changed the output of link "
 +                              . "with url {$url} and text {$text} to {$link}\n", true );
                        return $link;
                }
                $attribs['href'] = $url;
  
        /**
         * Make user link (or user contributions for unregistered users)
 -       * @param $userId   Integer: user id in database.
 -       * @param string $userName user name in database.
 -       * @param string $altUserName text to display instead of the user name (optional)
 -       * @return String: HTML fragment
 +       * @param int $userId User id in database.
 +       * @param string $userName User name in database.
 +       * @param string $altUserName Text to display instead of the user name (optional)
 +       * @return string HTML fragment
         * @since 1.19 Method exists for a long time. $altUserName was added in 1.19.
         */
        public static function userLink( $userId, $userName, $altUserName = false ) {
 +              $classes = 'mw-userlink';
                if ( $userId == 0 ) {
                        $page = SpecialPage::getTitleFor( 'Contributions', $userName );
                        if ( $altUserName === false ) {
                                $altUserName = IP::prettifyIP( $userName );
                        }
 +                      $classes .= ' mw-anonuserlink'; // Separate link class for anons (bug 43179)
                } else {
                        $page = Title::makeTitle( NS_USER, $userName );
                }
                return self::link(
                        $page,
                        htmlspecialchars( $altUserName !== false ? $altUserName : $userName ),
 -                      array( 'class' => 'mw-userlink' )
 +                      array( 'class' => $classes )
                );
        }
  
        /**
         * Generate standard user tool links (talk, contributions, block link, etc.)
         *
 -       * @param $userId Integer: user identifier
 -       * @param string $userText user name or IP address
 -       * @param $redContribsWhenNoEdits Boolean: should the contributions link be
 -       *        red if the user has no edits?
 -       * @param $flags Integer: customisation flags (e.g. Linker::TOOL_LINKS_NOBLOCK and Linker::TOOL_LINKS_EMAIL)
 -       * @param $edits Integer: user edit count (optional, for performance)
 -       * @return String: HTML fragment
 +       * @param int $userId User identifier
 +       * @param string $userText User name or IP address
 +       * @param bool $redContribsWhenNoEdits Should the contributions link be
 +       *   red if the user has no edits?
 +       * @param int $flags Customisation flags (e.g. Linker::TOOL_LINKS_NOBLOCK
 +       *   and Linker::TOOL_LINKS_EMAIL).
 +       * @param int $edits User edit count (optional, for performance)
 +       * @return string HTML fragment
         */
        public static function userToolLinks(
                $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null
  
        /**
         * Alias for userToolLinks( $userId, $userText, true );
 -       * @param $userId Integer: user identifier
 -       * @param string $userText user name or IP address
 -       * @param $edits Integer: user edit count (optional, for performance)
 -       * @return String
 +       * @param int $userId User identifier
 +       * @param string $userText User name or IP address
 +       * @param int $edits User edit count (optional, for performance)
 +       * @return string
         */
        public static function userToolLinksRedContribs( $userId, $userText, $edits = null ) {
                return self::userToolLinks( $userId, $userText, true, 0, $edits );
        }
  
        /**
 -       * @param $userId Integer: user id in database.
 -       * @param string $userText user name in database.
 -       * @return String: HTML fragment with user talk link
 +       * @param int $userId User id in database.
 +       * @param string $userText User name in database.
 +       * @return string HTML fragment with user talk link
         */
        public static function userTalkLink( $userId, $userText ) {
                $userTalkPage = Title::makeTitle( NS_USER_TALK, $userText );
        }
  
        /**
 -       * @param $userId Integer: userid
 -       * @param string $userText user name in database.
 -       * @return String: HTML fragment with block link
 +       * @param int $userId Userid
 +       * @param string $userText User name in database.
 +       * @return string HTML fragment with block link
         */
        public static function blockLink( $userId, $userText ) {
                $blockPage = SpecialPage::getTitleFor( 'Block', $userText );
        }
  
        /**
 -       * @param $userId Integer: userid
 -       * @param string $userText user name in database.
 -       * @return String: HTML fragment with e-mail user link
 +       * @param int $userId Userid
 +       * @param string $userText User name in database.
 +       * @return string HTML fragment with e-mail user link
         */
        public static function emailLink( $userId, $userText ) {
                $emailPage = SpecialPage::getTitleFor( 'Emailuser', $userText );
  
        /**
         * Generate a user link if the current user is allowed to view it
 -       * @param $rev Revision object.
 -       * @param $isPublic Boolean: show only if all users can see it
 -       * @return String: HTML fragment
 +       * @param Revision $rev
 +       * @param bool $isPublic Show only if all users can see it
 +       * @return string HTML fragment
         */
        public static function revUserLink( $rev, $isPublic = false ) {
                if ( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) {
  
        /**
         * Generate a user tool link cluster if the current user is allowed to view it
 -       * @param $rev Revision object.
 -       * @param $isPublic Boolean: show only if all users can see it
 +       * @param Revision $rev
 +       * @param bool $isPublic Show only if all users can see it
         * @return string HTML
         */
        public static function revUserTools( $rev, $isPublic = false ) {
         * Since you can't set a default parameter for a reference, I've turned it
         * temporarily to a value pass. Should be adjusted further. --brion
         *
 -       * @param $comment String
 -       * @param $title Mixed: Title object (to generate link to the section in autocomment) or null
 -       * @param $local Boolean: whether section links should refer to local page
 -       * @return mixed|String
 +       * @param string $comment
 +       * @param Title|null $title Title object (to generate link to the section in autocomment) or null
 +       * @param bool $local Whether section links should refer to local page
 +       * @return mixed|string
         */
        public static function formatComment( $comment, $title = null, $local = false ) {
                wfProfileIn( __METHOD__ );
                return $comment;
        }
  
 -      /**
 -       * @var Title
 -       */
 -      static $autocommentTitle;
 -      static $autocommentLocal;
 +      /** @var Title */
 +      private static $autocommentTitle;
 +
 +      /** @var bool Whether section links should refer to local page */
 +      private static $autocommentLocal;
  
        /**
         * Converts autogenerated comments in edit summaries into section links.
         * add a separator where needed and format the comment itself with CSS
         * Called by Linker::formatComment.
         *
 -       * @param string $comment comment text
 -       * @param $title Title|null An optional title object used to links to sections
 -       * @param $local Boolean: whether section links should refer to local page
 -       * @return String: formatted comment
 +       * @param string $comment Comment text
 +       * @param Title|null $title An optional title object used to links to sections
 +       * @param bool $local Whether section links should refer to local page
 +       * @return string Formatted comment
         */
        private static function formatAutocomments( $comment, $title = null, $local = false ) {
                // Bah!
  
        /**
         * Helper function for Linker::formatAutocomments
 -       * @param $match
 +       * @param array $match
         * @return string
         */
        private static function formatAutocommentsCallback( $match ) {
                                $auto .= wfMessage( 'colon-separator' )->inContentLanguage()->escaped();
                        }
                        $auto = '<span class="autocomment">' . $auto . '</span>';
 -                      $comment = $pre . $link . $wgLang->getDirMark() . '<span dir="auto">' . $auto . $post . '</span>';
 +                      $comment = $pre . $link . $wgLang->getDirMark()
 +                              . '<span dir="auto">' . $auto . $post . '</span>';
                }
                return $comment;
        }
  
 -      /**
 -       * @var Title
 -       */
 -      static $commentContextTitle;
 -      static $commentLocal;
 +      /** @var Title */
 +      private static $commentContextTitle;
 +
 +      /** @var bool Whether section links should refer to local page */
 +      private static $commentLocal;
  
        /**
         * Formats wiki links and media links in text; all other wiki formatting
         * is ignored
         *
         * @todo FIXME: Doesn't handle sub-links as in image thumb texts like the main parser
 -       * @param string $comment text to format links in
 -       * @param $title Title|null An optional title object used to links to sections
 -       * @param $local Boolean: whether section links should refer to local page
 -       * @return String
 +       * @param string $comment Text to format links in
 +       * @param Title|null $title An optional title object used to links to sections
 +       * @param bool $local Whether section links should refer to local page
 +       * @return string
         */
        public static function formatLinksInComment( $comment, $title = null, $local = false ) {
                self::$commentContextTitle = $title;
        }
  
        /**
 -       * @param $match
 +       * @param array $match
         * @return mixed
         */
        protected static function formatLinksInCommentCallback( $match ) {
                }
                if ( $thelink ) {
                        // If the link is still valid, go ahead and replace it in!
 -                      $comment = preg_replace( $linkRegexp, StringUtils::escapeRegexReplacement( $thelink ), $comment, 1 );
 +                      $comment = preg_replace(
 +                              $linkRegexp,
 +                              StringUtils::escapeRegexReplacement( $thelink ),
 +                              $comment,
 +                              1
 +                      );
                }
  
                return $comment;
        }
  
        /**
 -       * @param $contextTitle Title
 -       * @param $target
 -       * @param $text
 +       * @param Title $contextTitle
 +       * @param string $target
 +       * @param string $text
         * @return string
         */
        public static function normalizeSubpageLink( $contextTitle, $target, &$text ) {
         * Wrap a comment in standard punctuation and formatting if
         * it's non-empty, otherwise return empty string.
         *
 -       * @param $comment String
 -       * @param $title Mixed: Title object (to generate link to section in autocomment) or null
 -       * @param $local Boolean: whether section links should refer to local page
 +       * @param string $comment
 +       * @param Title|null $title Title object (to generate link to section in autocomment) or null
 +       * @param bool $local Whether section links should refer to local page
         *
         * @return string
         */
         * Wrap and format the given revision's comment block, if the current
         * user is allowed to view it.
         *
 -       * @param $rev Revision object
 -       * @param $local Boolean: whether section links should refer to local page
 -       * @param $isPublic Boolean: show only if all users can see it
 -       * @return String: HTML fragment
 +       * @param Revision $rev
 +       * @param bool $local Whether section links should refer to local page
 +       * @param bool $isPublic Show only if all users can see it
 +       * @return string HTML fragment
         */
        public static function revComment( Revision $rev, $local = false, $isPublic = false ) {
                if ( $rev->getRawComment() == "" ) {
        }
  
        /**
 -       * @param $size
 +       * @param int $size
         * @return string
         */
        public static function formatRevisionSize( $size ) {
        /**
         * Finish one or more sublevels on the Table of Contents
         *
 +       * @param int $level
         * @return string
         */
        public static function tocUnindent( $level ) {
        /**
         * parameter level defines if we are on an indentation level
         *
 +       * @param string $anchor
 +       * @param string $tocline
 +       * @param string $tocnumber
 +       * @param string $level
 +       * @param string|bool $sectionIndex
         * @return string
         */
        public static function tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex = false ) {
        /**
         * Wraps the TOC in a table and provides the hide/collapse javascript.
         *
 -       * @param string $toc html of the Table Of Contents
 -       * @param $lang String|Language|false: Language for the toc title, defaults to user language
 -       * @return String: full html of the TOC
 +       * @param string $toc Html of the Table Of Contents
 +       * @param string|Language|bool $lang Language for the toc title, defaults to user language
 +       * @return string Full html of the TOC
         */
        public static function tocList( $toc, $lang = false ) {
                $lang = wfGetLangObj( $lang );
         * Currently unused.
         *
         * @param array $tree Return value of ParserOutput::getSections()
 -       * @return String: HTML fragment
 +       * @return string HTML fragment
         */
        public static function generateTOC( $tree ) {
                $toc = '';
        /**
         * Create a headline for content
         *
 -       * @param $level Integer: the level of the headline (1-6)
 -       * @param string $attribs any attributes for the headline, starting with
 -       *                 a space and ending with '>'
 -       *                 This *must* be at least '>' for no attribs
 -       * @param string $anchor the anchor to give the headline (the bit after the #)
 -       * @param string $html html for the text of the header
 +       * @param int $level The level of the headline (1-6)
 +       * @param string $attribs Any attributes for the headline, starting with
 +       *   a space and ending with '>'
 +       *   This *must* be at least '>' for no attribs
 +       * @param string $anchor The anchor to give the headline (the bit after the #)
 +       * @param string $html Html for the text of the header
         * @param string $link HTML to add for the section edit link
 -       * @param $legacyAnchor Mixed: a second, optional anchor to give for
 +       * @param bool|string $legacyAnchor A second, optional anchor to give for
         *   backward compatibility (false to omit)
         *
 -       * @return String: HTML headline
 +       * @return string HTML headline
         */
 -      public static function makeHeadline( $level, $attribs, $anchor, $html, $link, $legacyAnchor = false ) {
 +      public static function makeHeadline( $level, $attribs, $anchor, $html,
 +              $link, $legacyAnchor = false
 +      ) {
                $ret = "<h$level$attribs"
                        . "<span class=\"mw-headline\" id=\"$anchor\">$html</span>"
                        . $link
        /**
         * Split a link trail, return the "inside" portion and the remainder of the trail
         * as a two-element array
 +       * @param string $trail
         * @return array
         */
        static function splitTrail( $trail ) {
         *
         * If the option noBrackets is set the rollback link wont be enclosed in []
         *
 -       * @param $rev Revision object
 -       * @param $context IContextSource context to use or null for the main context.
 -       * @param $options array
 +       * @param Revision $rev
 +       * @param IContextSource $context Context to use or null for the main context.
 +       * @param array $options
         * @return string
         */
 -      public static function generateRollback( $rev, IContextSource $context = null, $options = array( 'verify' ) ) {
 +      public static function generateRollback( $rev, IContextSource $context = null,
 +              $options = array( 'verify' )
 +      ) {
                if ( $context === null ) {
                        $context = RequestContext::getMain();
                }
 +
                $editCount = false;
                if ( in_array( 'verify', $options ) ) {
                        $editCount = self::getRollbackEditCount( $rev, true );
         * Returns null if $wgShowRollbackEditCount is disabled or false if $verify
         * is set and the user is the only contributor of the page.
         *
 -       * @param $rev Revision object
 +       * @param Revision $rev
         * @param bool $verify Try to verify that this revision can really be rolled back
 -       * @return integer|bool|null
 +       * @return int|bool|null
         */
        public static function getRollbackEditCount( $rev, $verify ) {
                global $wgShowRollbackEditCount;
                $moreRevs = false;
                foreach ( $res as $row ) {
                        if ( $rev->getRawUserText() != $row->rev_user_text ) {
 -                              if ( $verify && ( $row->rev_deleted & Revision::DELETED_TEXT || $row->rev_deleted & Revision::DELETED_USER ) ) {
 -                                      // If the user or the text of the revision we might rollback to is deleted in some way we can't rollback
 -                                      // Similar to the sanity checks in WikiPage::commitRollback
 +                              if ( $verify &&
 +                                      ( $row->rev_deleted & Revision::DELETED_TEXT
 +                                              || $row->rev_deleted & Revision::DELETED_USER
 +                              ) ) {
 +                                      // If the user or the text of the revision we might rollback
 +                                      // to is deleted in some way we can't rollback. Similar to
 +                                      // the sanity checks in WikiPage::commitRollback.
                                        return false;
                                }
                                $moreRevs = true;
        /**
         * Build a raw rollback link, useful for collections of "tool" links
         *
 -       * @param $rev Revision object
 -       * @param $context IContextSource context to use or null for the main context.
 -       * @param $editCount integer Number of edits that would be reverted
 -       * @return String: HTML fragment
 +       * @param Revision $rev
 +       * @param IContextSource|null $context Context to use or null for the main context.
 +       * @param int $editCount Number of edits that would be reverted
 +       * @return string HTML fragment
         */
 -      public static function buildRollbackLink( $rev, IContextSource $context = null, $editCount = false ) {
 +      public static function buildRollbackLink( $rev, IContextSource $context = null,
 +              $editCount = false
 +      ) {
                global $wgShowRollbackEditCount, $wgMiserMode;
  
                // To config which pages are effected by miser mode
                $query = array(
                        'action' => 'rollback',
                        'from' => $rev->getUserText(),
 -                      'token' => $context->getUser()->getEditToken( array( $title->getPrefixedText(), $rev->getUserText() ) ),
 +                      'token' => $context->getUser()->getEditToken( array(
 +                              $title->getPrefixedText(),
 +                              $rev->getUserText()
 +                      ) ),
                );
                if ( $context->getRequest()->getBool( 'bot' ) ) {
                        $query['bot'] = '1';
                        }
                }
  
 -              if ( !$disableRollbackEditCount && is_int( $wgShowRollbackEditCount ) && $wgShowRollbackEditCount > 0 ) {
 +              if ( !$disableRollbackEditCount
 +                      && is_int( $wgShowRollbackEditCount )
 +                      && $wgShowRollbackEditCount > 0
 +              ) {
                        if ( !is_numeric( $editCount ) ) {
                                $editCount = self::getRollbackEditCount( $rev, false );
                        }
  
                        if ( $editCount > $wgShowRollbackEditCount ) {
 -                              $editCount_output = $context->msg( 'rollbacklinkcount-morethan' )->numParams( $wgShowRollbackEditCount )->parse();
 +                              $editCount_output = $context->msg( 'rollbacklinkcount-morethan' )
 +                                      ->numParams( $wgShowRollbackEditCount )->parse();
                        } else {
                                $editCount_output = $context->msg( 'rollbacklinkcount' )->numParams( $editCount )->parse();
                        }
         * @param bool $preview Whether this is for a preview
         * @param bool $section Whether this is for a section edit
         * @param Title|Message|string|null $more An escaped link for "More..." of the templates
 -       * @return String: HTML output
 +       * @return string HTML output
         */
 -      public static function formatTemplates( $templates, $preview = false, $section = false, $more = null ) {
 +      public static function formatTemplates( $templates, $preview = false,
 +              $section = false, $more = null
 +      ) {
                global $wgLang;
                wfProfileIn( __METHOD__ );
  
        /**
         * Returns HTML for the "hidden categories on this page" list.
         *
 -       * @param array $hiddencats of hidden categories from Article::getHiddenCategories
 -       * or similar
 -       * @return String: HTML output
 +       * @param array $hiddencats Array of hidden categories from Article::getHiddenCategories
 +       *   or similar
 +       * @return string HTML output
         */
        public static function formatHiddenCategories( $hiddencats ) {
                wfProfileIn( __METHOD__ );
                        $outText .= "</div><ul>\n";
  
                        foreach ( $hiddencats as $titleObj ) {
 -                              $outText .= '<li>' . self::link( $titleObj, null, array(), array(), 'known' ) . "</li>\n"; # If it's hidden, it must exist - no need to check with a LinkBatch
 +                              # If it's hidden, it must exist - no need to check with a LinkBatch
 +                              $outText .= '<li>'
 +                                      . self::link( $titleObj, null, array(), array(), 'known' )
 +                                      . "</li>\n";
                        }
                        $outText .= '</ul>';
                }
         * unit (B, KB, MB or GB) according to the magnitude in question
         *
         * @param int $size Size to format
 -       * @return String
 +       * @return string
         */
        public static function formatSize( $size ) {
                global $wgLang;
         * isn't always, because sometimes the accesskey needs to go on a different
         * element than the id, for reverse-compatibility, etc.)
         *
 -       * @param string $name id of the element, minus prefixes.
 -       * @param $options Mixed: null or the string 'withaccess' to add an access-
 +       * @param string $name Id of the element, minus prefixes.
 +       * @param string|null $options Null or the string 'withaccess' to add an access-
         *   key hint
 -       * @return String: contents of the title attribute (which you must HTML-
 +       * @return string Contents of the title attribute (which you must HTML-
         *   escape), or false for no title attribute
         */
        public static function titleAttrib( $name, $options = null ) {
                if ( $options == 'withaccess' ) {
                        $accesskey = self::accesskey( $name );
                        if ( $accesskey !== false ) {
 +                              // Should be build the same as in jquery.accessKeyLabel.js
                                if ( $tooltip === false || $tooltip === '' ) {
 -                                      $tooltip = wfMessage( 'brackets', $accesskey )->escaped();
 +                                      $tooltip = wfMessage( 'brackets', $accesskey )->text();
                                } else {
 -                                      $tooltip .= wfMessage( 'word-separator' )->escaped();
 -                                      $tooltip .= wfMessage( 'brackets', $accesskey )->escaped();
 +                                      $tooltip .= wfMessage( 'word-separator' )->text();
 +                                      $tooltip .= wfMessage( 'brackets', $accesskey )->text();
                                }
                        }
                }
                return $tooltip;
        }
  
 -      static $accesskeycache;
 +      private static $accesskeycache;
  
        /**
         * Given the id of an interface element, constructs the appropriate
         * the id but isn't always, because sometimes the accesskey needs to go on
         * a different element than the id, for reverse-compatibility, etc.)
         *
 -       * @param string $name id of the element, minus prefixes.
 -       * @return String: contents of the accesskey attribute (which you must HTML-
 +       * @param string $name Id of the element, minus prefixes.
 +       * @return string Contents of the accesskey attribute (which you must HTML-
         *   escape), or false for no accesskey attribute
         */
        public static function accesskey( $name ) {
        /**
         * Creates a (show/hide) link for deleting revisions/log entries
         *
 -       * @param array $query query parameters to be passed to link()
 -       * @param $restricted Boolean: set to true to use a "<strong>" instead of a "<span>"
 -       * @param $delete Boolean: set to true to use (show/hide) rather than (show)
 +       * @param array $query Query parameters to be passed to link()
 +       * @param bool $restricted Set to true to use a "<strong>" instead of a "<span>"
 +       * @param bool $delete Set to true to use (show/hide) rather than (show)
         *
 -       * @return String: HTML "<a>" link to Special:Revisiondelete, wrapped in a
 +       * @return string HTML "<a>" link to Special:Revisiondelete, wrapped in a
         * span to allow for customization of appearance with CSS
         */
        public static function revDeleteLink( $query = array(), $restricted = false, $delete = true ) {
                $html = wfMessage( $msgKey )->escaped();
                $tag = $restricted ? 'strong' : 'span';
                $link = self::link( $sp, $html, array(), $query, array( 'known', 'noclasses' ) );
 -              return Xml::tags( $tag, array( 'class' => 'mw-revdelundel-link' ), wfMessage( 'parentheses' )->rawParams( $link )->escaped() );
 +              return Xml::tags(
 +                      $tag,
 +                      array( 'class' => 'mw-revdelundel-link' ),
 +                      wfMessage( 'parentheses' )->rawParams( $link )->escaped()
 +              );
        }
  
        /**
         * Creates a dead (show/hide) link for deleting revisions/log entries
         *
 -       * @param $delete Boolean: set to true to use (show/hide) rather than (show)
 +       * @param bool $delete Set to true to use (show/hide) rather than (show)
         *
         * @return string HTML text wrapped in a span to allow for customization
         * of appearance with CSS
         * call this lots of times, pre-fill the link cache with a LinkBatch, otherwise each
         * call to this will result in a DB query.
         *
 -       * @param $nt     Title: the title object to make the link from, e.g. from
 -       *                      Title::newFromText.
 -       * @param $text  String: link text
 -       * @param string $query optional query part
 -       * @param string $trail optional trail. Alphabetic characters at the start of this string will
 -       *                      be included in the link text. Other characters will be appended after
 -       *                      the end of the link.
 -       * @param string $prefix optional prefix. As trail, only before instead of after.
 +       * @param Title $nt The title object to make the link from, e.g. from Title::newFromText.
 +       * @param string $text Link text
 +       * @param string $query Optional query part
 +       * @param string $trail Optional trail. Alphabetic characters at the start of this string will
 +       *   be included in the link text. Other characters will be appended after
 +       *   the end of the link.
 +       * @param string $prefix Optional prefix. As trail, only before instead of after.
         * @return string
         */
        static function makeLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
         * it doesn't have to do a database query. It's also valid for interwiki titles and special
         * pages.
         *
 -       * @param $title  Title object of target page
 -       * @param $text   String: text to replace the title
 -       * @param $query  String: link target
 -       * @param $trail  String: text after link
 -       * @param string $prefix text before link text
 -       * @param string $aprops extra attributes to the a-element
 -       * @param $style  String: style to apply - if empty, use getInternalLinkAttributesObj instead
 -       * @return string the a-element
 +       * @param Title $title Title object of target page
 +       * @param string $text Text to replace the title
 +       * @param string $query Link target
 +       * @param string $trail Text after link
 +       * @param string $prefix Text before link text
 +       * @param string $aprops Extra attributes to the a-element
 +       * @param string $style Style to apply - if empty, use getInternalLinkAttributesObj instead
 +       * @return string The a-element
         */
        static function makeKnownLinkObj(
                $title, $text = '', $query = '', $trail = '', $prefix = '', $aprops = '', $style = ''
  
        /**
         * Returns the attributes for the tooltip and access key.
 +       * @param string $name
         * @return array
         */
        public static function tooltipAndAccesskeyAttribs( $name ) {
  
        /**
         * Returns raw bits of HTML, use titleAttrib()
 +       * @param string $name
 +       * @param array|null $options
         * @return null|string
         */
        public static function tooltip( $name, $options = null ) {